package org.glut.backend.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * 支付宝配置类
 *
 * @author xiuci1412
 * @since 2025-08-01 17:43
 */
@Configuration
@Data
public class AlipayConfig {

	@Value("${alipay.appId}")
	public String appId;

	@Value("${alipay.privateKey}")
	public String privateKey;

	@Value("${alipay.publicKey}")
	public String publicKey;

	public String signType = "RSA2";
	
	// 字符编码格式
	public static String charset = "utf-8";
	
	@Bean
	public AlipayClient alipayClient(){
		return new DefaultAlipayClient("https://openapi-sandbox.dl.alipaydev.com/gateway.do", appId,
				privateKey, "json", AlipayConfig.charset, publicKey, signType);
	}
	
}

